package com.jinjia.ordersys.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description: swagger配置类
 * @Author: fenghouzhi
 * @Date: 11:03 AM 2018/10/9
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Value(value = "${swagger.enabled}")
    Boolean swaggerEnabled;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .enable(swaggerEnabled).select()
                .apis(RequestHandlerSelectors.basePackage("com.jinjia.ordersys.controller"))
                .paths(PathSelectors.any()).build().pathMapping("");
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("金甲订单系统-API")
                .description("小智")
                .contact(new Contact("fhz", "http://blog.osnooker.com", "13718913664@163.com"))
                .version("1.0.0")
                .build();
    }

}